package com.dc.refactoring._3_重新组织数据._6_ChangeUnidirectionalAssociationToBidirectional.step3;

import com.google.common.collect.Sets;

import java.util.Set;

/**
 * Description: 当前演示的是多对多的关系，一个订单也可以有多个客户的场景
 * @author: gdc
 * @date: 2020/11/17
 * @version 1.0
 */
public class Order {

    private Set<Customer> customers = Sets.newHashSet();

    public void addCustomer(Customer arg) {
        arg.friendOrders().add(this);
        customers.add(arg);
    }

    public void removeCustomer(Customer arg) {
        arg.friendOrders().remove(this);
        customers.remove(arg);
    }
}
